package main

import (
	"context"
	"fmt"
	"github.com/tencentyun/cos-go-sdk-v5"
	"net/http"
	"os"
)

const SECRETID = "AKIDRFFE8qQ2Xr46GJ8nGUZkvEWwCKPc2WvF"
const SECRETKEY = "YxRly4AHiGm9eM3jYOweHzhP2nV6pV4d"

/*
personcard 	人卡管理 人卡cos配置

	{
	  "url": "https://zn-xz-tx-personcard-1258638997.cos-internal.ap-guangzhou.tencentcos.cn",
	  "secret_id": "AKIDRFFE8qQ2Xr46GJ8nGUZkvEWwCKPc2WvF",
	  "secret_key": "YxRly4AHiGm9eM3jYOweHzhP2nV6pV4d",
	  "directory": "xz/outsiders/serviceprovider/temporary",
	  "doc_preview": true,
	  "local_directory": "/Users/xiangyang/Desktop/code/ecardpic/",
	  "data_directory": "xz/outsiders/dataexport"
	}
*/
func main() {
	fmt.Println("学习使用cos")

}

// GetCosList 查询存储桶列表 https://cloud.tencent.com/document/product/436/31215
func GetCosList() {
	c := cos.NewClient(nil, &http.Client{
		Transport: &cos.AuthorizationTransport{
			SecretID:  os.Getenv(SECRETID),  // 用户的 SecretId，建议使用子账号密钥，授权遵循最小权限指引，降低使用风险。子账号密钥获取可参考 https://cloud.tencent.com/document/product/598/37140
			SecretKey: os.Getenv(SECRETKEY), // 用户的 SecretKey，建议使用子账号密钥，授权遵循最小权限指引，降低使用风险。子账号密钥获取可参考 https://cloud.tencent.com/document/product/598/37140
		},
	})

	s, _, err := c.Service.Get(context.Background())
	if err != nil {
		panic(err)
	}

	for _, b := range s.Buckets {
		fmt.Printf("%#v\n", b)
	}

}
